Microprocessors, microcontrollers, and signal processors are examples of programmable units. The processor architecture which is chosen for the programmable unit, in conjunction with the respectively chosen compiler technology and the respective application, essentially governs the performance, the speed and the flexibility of the programmable unit.
An assembler programming language which has a fixed instruction set based on a register model is available to the user of the programmable unit for hardware-related programming.
Examples of programmable units such as these are the processors in the C166 family with a 16-bit architecture, as well as TriCore, with a 32-bit architecture from Infineon Technologies AG. These programmable units have a memory device, an instruction decoding, address and data register, a pipeline as well as a barrel shifter (register that is able to shift its content by up to as much bits as the length of the register allows) and bit mask generator for processing of the bit instructions. Modern programmable units, in particular processors with a pipeline architecture or protocol processors, have bit field manipulation as an additional functionality. In bit field manipulation, a bit segment comprising one or more bits which is or are contained in a first data string is taken from the first data string, is processed, and is inserted into a corresponding bit field in a second data string. A data string may, for example, contain a word (32 bits), a double word (64 bits), a half-word (16 bits), etc.
With regard to the general background of programmable units with bit field manipulation, reference is made to U.S. Pat. No. 6,061,783, US Patent Application US 2002/0120828 A1 and the specification for the TriCore microcontroller, as mentioned initially, from Infineon Technologies AG. The entire contents of these documents relating to bit field manipulation are herein incorporated by reference.
One normal instruction for bit field manipulation is the “Move” instruction, in which a number of bits are taken from a first data word and, after appropriate modification, are inserted into a second data word. This “Move” instruction for bit field manipulation has the following structure in the assembler programming language:MVR R #offset1 Rs #offset0 #bits
The “Move” instruction MVR results in a bit segment with a bit length of #bits being moved from the source register Rs at the bit position #offset0 to the destination register Rd at the bit position #offset1. In formal terms, this operation is described as follows:Rd(#bits, #offset1)<=Rs(#bits, #offset0)
A large number of individual program codes are required in order to implement this “Move” instruction with a simple instruction set. This implementation of the “Move” instruction will be described by way of example in the following text:
mvrR2 0 R1 0 8// take first byteaddiR3 R2 1// process the bytestrR15 R3// store the resultmvrR2 0 R1 8 8// take the second byte, etc.addiR3 R2 1strR15 R3mvrR2 0 R1 16 8addiR3 R2 1strR15 R3mvrR2 0 R1 24 8addiR3 R2 1strR15 0 R3 32 0 0
The first line in the program indicates that a first byte (8 bits) should be taken at the bit position 0 at a first point R1 in the source register, and should be moved to a bit position at a second point R2. The second line indicates that this bit is in fact processed (added) at the second point R2. The result R3 of the previous process step is inserted at the point R15 in the destination register, and is stored (third line). These process steps are repeated until all 32 bits, that is to say the entire word, have been taken from the source register, have been processed and have been written to the destination register. In a corresponding manner, therefore, the second byte is taken at the bit position 8, and is passed on, on the basis of the fourth line in the above program.
As can be seen, a total of 12 instruction steps (program codes) are required in this case for the simple function of the “Move” instruction. One disadvantage of a large number of instruction steps is that the instruction memory becomes larger. Owing to frequent accesses to the instruction memory, this leads directly to more energy being consumed. Furthermore, a large number of instruction steps also leads to a correspondingly physically large memory, which in the end also increases the chip area and therefore additionally makes the entire programmable unit more expensive.
The above problem has been described for a programmable unit with direct register addressing. With this type of addressing, the address (or the number) of the register is indicated directly as an (immediate) value.
Furthermore, register-indirect addressing also exists, in which the address of the register is the content of another register. This type of addressing has the advantage over direct addressing that the operand address need not be read at the same time when fetching the instruction. This is used when the same operand address is accessed frequently within one program section.
One development is register-indirect addressing with displacement, in which the current address is calculated from the content of an address register by a constant address displacement (displacement). This address displacement is signed (two's complement) and thus allows a positive as well as a negative address displacement from the base address in the address register. This method is used for those data accesses which occur in a fixed structure in the memory. The same element in the next data set is thus accessed by changing the base address in the address register, or a variable base address can be taken into account.
Processors without the capability for indirect memory addressing would, for example, have to store three individual bits in a data word with a length of 32 bits, for a 32-bit memory. The other 29 bits of this data word then remain unused. This form of indirect data addressing, which is also referred to in the following text as bit field access to the data memory, thus significantly reduces the memory size of the data memory, and thus also the chip area. Such bit field access to the data memory does not, however, have any loop with sequential access to individual bit structures since the bit positions and their offset value are predetermined as constant values (so-called immediate values) for each of the accesses. One problem that is associated with this is also that the number of memory accesses always remains the same, so that no energy is saved in comparison to conventional memory accesses.
This problem will be illustrated using the following program, which describes the initially described “Move” instruction MVR for register-indirect addressing:
ldiR1 0 0x030// load read pointer = 0x30ldiR3 0 0x040// load write pointer = 0x40ldrR2 0 R1 0 8// take first bytenopnopaddiR3R2 1// process the bytestrR15 R3// store the resultldrR2 0 R1 8 8// take the second bytenopnopaddiR3 R2 1strR15 R3ldrR2 0 R1 16 8// take the third bytenopnopaddiR3 R2 1strR15 R3ldrR2 0 R1 24 8// take the fourth bytenopnopaddiR3 R2 1strR15 0 R3 32 0 0
The first two lines indicate that a read pointer and a write pointer to the corresponding points R1, R3 are loaded. The first byte is then loaded (third line). After two program steps (fourth and fifth lines) in which no operation is provided, the byte that has been read is processed in the sixth line, and is stored as the result in the seventh line. This procedure is repeated until all four bytes have been read. This therefore results in a total of 22 instruction steps for the “Move” instruction, that is to say in order to shift a single word comprising 32 bits out of the memory. However, a large number of instruction steps and frequent accesses to the memory lead to the programmable unit having a high power consumption and, in addition, lead to a large chip area.
When using a programmable unit, in particular a programmable unit with a fixed instruction set, there is thus a need to carry out frequently recurring functions more effectively within a program to be executed.